package com.github.shiqiyue.learn.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.NodeCache;

import java.io.IOException;

/***
 * nodecache 测试
 * @author wenyao.wu
 * @date 2019/1/21
 */
public class NodeCacheTest {

    public static void main(String[] args) throws Exception {
        CuratorFramework client = ClientUtil.getClient(null);

        NodeCache watcher = new NodeCache(client, "/t1");

        watcher.getListenable().addListener(()->{
            String value = new String(watcher.getCurrentData().getData());
            System.out.println(value);
        });
        watcher.start(true);
        System.in.read();
        client.close();
    }
}
